#ifndef __KA_TOOLS_H__
#define __KA_TOOLS_H__
#include <tee_internal_api.h>

#define SHA1_DIGEST_SIZE 20

const char *uuid2str(const unsigned char *uuid);

const char *hexStr(const uint8_t *buf, int len);

TEE_Result caculate_client_uuid(const char *full_path, TEE_UUID *uuid);

TEE_Result KA_ACL_Create(TEE_ObjectHandle *object, TEE_UUID uuid);
TEE_Result KA_ACL_Open(TEE_ObjectHandle *object, TEE_UUID uuid);
void KA_ACL_Close(TEE_ObjectHandle object);
TEE_Result KA_ACL_Find(TEE_ObjectHandle object, TEE_UUID uuid);
TEE_Result KA_ACL_Delete(TEE_ObjectHandle object, TEE_UUID uuid);
TEE_Result KA_ACL_Add(TEE_ObjectHandle object, TEE_UUID uuid);

/* user */
TEE_Result KA_CMD_Find(TEE_UUID host, TEE_UUID guest);
TEE_Result KA_CMD_GetPublicKey(TEE_UUID uuid, void *n, size_t *n_size, void *e, size_t *e_size);
TEE_Result KA_CMD_GetPrivateKey(TEE_UUID uuid, void *n, size_t *n_size, void *e, size_t *e_size, void *d, size_t *d_size, void *p, size_t *p_size, void *q, size_t *q_size, void *dmp1, size_t *dmp1_size, void *dmq1, size_t *dmq1_size, void *iqmp, size_t *iqmp_size);
TEE_Result KA_CMD_GetPrivateKey0(TEE_UUID uuid, void *n, size_t *n_size, void *e, size_t *e_size, void *d, size_t *d_size, void *p, size_t *p_size);
TEE_Result KA_CMD_GetPrivateKey1(TEE_UUID uuid, void *q, size_t *q_size, void *dmp1, size_t *dmp1_size, void *dmq1, size_t *dmq1_size, void *iqmp, size_t *iqmp_size);

/* admin */
TEE_Result KA_CMD_Remove(TEE_UUID uuid);
TEE_Result KA_CMD_Add(TEE_UUID host, TEE_UUID guest);
TEE_Result KA_CMD_Delete(TEE_UUID host, TEE_UUID guest);

TEE_Result KA_ADD(uint32_t param_types, TEE_Param params[4]);
TEE_Result KA_DELETE(uint32_t param_types, TEE_Param params[4]);
TEE_Result KA_REMOVE(uint32_t param_types, TEE_Param params[4]);
TEE_Result KA_RSA_PUB(uint32_t param_types, TEE_Param params[4]);
TEE_Result KA_RSA_PRI_0(uint32_t param_types, TEE_Param params[4]);
TEE_Result KA_RSA_PRI_1(uint32_t param_types, TEE_Param params[4]);
TEE_Result KA_TEST(uint32_t param_types, TEE_Param params[4]);

#endif
